function findParentNode(parentName, childObj) {
    var testObj = childObj.parentNode;
    var count = 1;
    while(testObj.getAttribute('class') != parentName) {
        //alert('My name is ' + testObj.getAttribute('class') + '. Let\'s try moving up one level to see what we get.');
        testObj = testObj.parentNode;
        count++;
    }
    return testObj; //we found it!
}

function randomString(sChrs,iLen)  {
		var sRnd = '';
			for (var i=0; i<iLen;i++){
				var randomPoz = Math.floor(Math.random() * sChrs.length);
				sRnd += sChrs.substring(randomPoz,randomPoz+1);
			}
	return sRnd;
}

function simulateEvent(eventType, targetElement) {
		var event;
	    targetElement = $(targetElement);
	    
	    if (targetElement) {
	     // check for IE
	     if (window.ActiveXObject) {
	         event = document.createEventObject();
	         targetElement.fireEvent("on"+eventType,event);
	     } else {
	         switch (eventType) {
	             case "abort":
	             case "blur":
	             case "change":
	             case "error":
	             case "focus":
	             case "load":
	             case "reset":
	             case "resize":
	             case "scroll":
	             case "select":
	             case "submit":
	             case "unload":
	                 event = document.createEvent("HTMLEvents");
	                 event.initEvent(eventType, "true", "true");
	                 break;
	             case "click":
	             case "mousedown":
	             case "mousemove":
	             case "mouseout":
	             case "mouseover":
	             case "mouseup":
	                 event = document.createEvent("MouseEvents");
	                 event.initMouseEvent(eventType, true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
	                 break;
	         }
	         targetElement.dispatchEvent(event);
	     }
	    }
}
